<template>
  <div class="contain">
     <!-- 走马灯  -->
    <div>
        <el-carousel  class="siwpers" height="50rem">
        <el-carousel-item v-for="item in swiperList" :key="item.id" :indicator-position="swiperList.length>0">
            <div class="siwpers-img">
                <img class="siwper-items" :src="item.img" alt="">
            </div>
        </el-carousel-item>
        </el-carousel>
    </div>
    <!-- 更多  -->
    <div class="title">
        <div class="title-title">热点文章</div>
        <div class="morePage">更多动态<el-icon><ArrowRight /></el-icon></div>
    </div>
    <!-- 信息卡片  -->
    <div class="article">
           <div v-for="item in comphotLists" :key="item.id" class="article-box">
                   <img :src="item.img" alt="#" class="article-img">
                   <div class="article-title">{{ item.title }}</div>
                   <div class="article-text">{{ item.introduce }}</div> 
                   <div class="article-time"><div class="time-lf"><el-icon style="color: #52B870;margin-right: 5px;"><Timer /></el-icon>{{ item.lastUpdateTime }}</div><div class="time-rh"><img class="time-img" @click="toDetail(item)" style="cursor: pointer;" src="@/assets/article-r.png" alt=""></div></div>
           </div>
    </div>
    <!-- 更多  -->
    <div class="title b-title">
        <div class="title-title ">最新果园资讯</div>
        <div class="morePage">查看更多<el-icon><ArrowRight /></el-icon></div>
    </div>
    <div class="information-nav">
        <div v-for="item in navlist" :key="item.id" class="nav-title" :class="chooseInfoHot.type==item.name?'active-title':''" @click="checknav(item)"><component class="icons" :is="item.icon"></component><span>{{ item.name }}</span></div>
    </div>
    <!-- 走马灯信息  -->
    <div class="information-img">
        <el-carousel  :interval="4000" type="card" height="30rem" class="information-swiper" indicator-position="none" arrow="always">
            <el-carousel-item v-for="item in homeShowLists" :key="item.id" class="information-item" :name="item.id" @click="toDetail(item)">
                <div class="img-bp">
                    <div class="center-msg">
                        <div class="center-title">{{ item.title }}</div>
                        <div class="center-text">{{ item.introduce }}</div>
                        <img class="center-img" src='../../assets/banners.png' alt="#">
                    </div>
                    <img class="bg-img" :src='item.img' alt="#">
                </div>
            </el-carousel-item>
        </el-carousel>
    </div>
    <!-- 底部图片  -->
    <div class="bottom-img">
        <img src="@/assets/bottoms.png" alt="#">
    </div>
    <!-- 底部信息  -->
    <div class="bottom-msg">
        <div class="banquan">果园农业种植数据管理平台 版权所有</div>
        <div class="tips"><span>使用前必读</span><span>帮助中心</span><span>京公网安备xxxxxxx号</span></div>
        <div class="compeny">互联网农业信息服务资格证书 (京)-经营性-2017-0020  ｜  信息网络传播视听节目许可证 xxxx </div>
    </div>
  </div>
</template>

<script setup>
import {getContentList,getBannerList} from '../../util/api.js'
const navlist = ref([
    {
        name:"政策分析",
        icon:"DataAnalysis",
        id:"1",
        imgs:"infomation"
    },
    {
        name:"违规曝光",
        icon:"OfficeBuilding",
        id:"2",
        imgs:"infomation"
    },
    {
        name:"专业知识",
        icon:"Reading",
        id:"3",
        imgs:"infomation"
    },
    {
        name:"行业资讯",
        icon:"Document",
        id:"4",
        imgs:"infomation"
    },
 ])
 const router = useRouter()
 const swiperList =ref([])
 const comphotLists = ref([])
 const homeShowLists = ref([])
 const checknav= (item)=>{
    chooseInfoHot.value.type = item.name
    findchooseHot()
 }
const compInfoHot = ref({
    type:"",
    state:2,
    pageNum:4,
    hotspot:true,
    homeShow:true,
    page: 1,
    pageType: 1
})
const chooseInfoHot = ref({
    type:"政策分析",
    state:2,
    homeShow:true,
})
  //查询热点文章
 const findCompHot = async()=>{
     let res= await getContentList(compInfoHot.value)
    console.log('热点文章：',res)
     if(res.code!=200)return
     comphotLists.value=res.data.content
}
const findchooseHot = async()=>{
     let res= await getContentList(chooseInfoHot.value)
     console.log('热点文章：',res)
     if(res.code!=200)return
     homeShowLists.value=res.data
}
const getBannerLists = async()=>{
            let res= await getBannerList({type:'新闻首页'})
            // console.log(res)
            if(res.code!=200)return
            swiperList.value=res.data
  }
const toDetail = (item)=>{
    router.push({
        path:"/analysisDetail",
        query:{
            data:encodeURIComponent(JSON.stringify(item))
        }
     })
}
onMounted(()=>{
    getBannerLists()
    findCompHot()   
    findchooseHot()
 })
</script>

<style lang="scss" scoped>
//调整走马灯箭头-左箭头
.contain{
    width:100%;
    .siwpers{
        width: 100%;
        height: 800px;
        :deep(.el-carousel__arrow--left){
                width: 60px;
                height: 60px;
                left: 80px;
                border: 1px solid #52B870;
                font-weight: 500;
                font-size: 16px;
                color: #52B870;
                background: none;
                }

                //右箭头
        :deep(.el-carousel__arrow--right){
        width: 60px;
        height: 60px;
        right: 80px;
        border: 1px solid #52B870;
        font-weight: 500;
        font-size: 16px;
        color: #52B870;
        background: none;
        }
        .siwpers-img{
            width: 100%;
            height: 800px;
            background-size: 100% 100%;
            .siwper-items{
                width: 100%;
                height: 100%;
            }
        }
    } 
    .title{
        text-align: center;
        font-size: 30px;
        padding: 60px 0;
        background-color: #F8F8F8;
        .title-title{
            font-size: 38px;
            font-weight: 500;
            color: #121212;
        }
        .morePage{
            font-size: 16px;
            font-weight: 500;
            color: #52B870;
            margin-top: 20px;
            cursor: pointer;
            display: inline-flex;
            align-items: center;
        }
    }
    .b-title{
        background-color: #ffffff;
    }
    .article{
        width: 100%;
        box-sizing: border-box;
        padding: 0 150px;
        background-color: #F8F8F8;
        display: flex;
        flex-wrap: wrap;
        padding-bottom: 60px;
        justify-content: center;
        gap: 20px;
        .article-box{
            width: 23%;
            margin-top: 40px;
            background-color: #FFFFFF;
            box-shadow: 0px 0px 16px 2px rgba(0,0,0,0.08);
            .article-img{
                display: block;
                width: 100%;
                height: 220px;
            }
            .article-title{
                font-size: 22px;
                box-sizing: border-box;
                padding: 0 20px;
                font-weight: 500;
                color: #323232;
            }
            .article-text{
                width: 100%;
                font-size: 18px;
                height: 120px;
                box-sizing: border-box;
                padding: 0 20px;
                font-weight: 400;
                color: #666666;
                word-break: break-all;
                text-overflow: ellipsis;
                display: -webkit-box;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 4; /* 这里是超出几行省略 */
                overflow: hidden;
            }
            .article-time{
                width:calc(100% - 40px);
                margin: 0 auto; 
                border-top: 1px solid rgba(0,0,0,0.12);
                box-sizing: border-box;
                padding: 20px 0;
                display: flex;
                align-items: center;
                justify-content: space-between;
                .time-lf{
                   display: flex;
                   align-items: center;
                }
            }
        }
    }
    .information-nav{
        width: calc(100% - 1000px);
        margin: 0 auto;
        display: flex;
        justify-content: space-between;
        .nav-title{
            font-size: 18px;
            font-weight: 400;
            padding: 0 10px;
            box-sizing: border-box;
            color: #666666;
            padding: 10px 0;
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .active-title{
            font-weight: 500;
            color: #52B870;
            font-size: 20px;
            border-bottom: 4px solid #52B870;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        .icons{
            width: 20px;
        }
    }
    .information-img{
        width: 100%;
        overflow: hidden;
        margin-top: 60px;
        .information-swiper{
            width: 160%;
            margin-left:-15%;
            :deep(.el-carousel__arrow--left){
                width: 40px;
                height: 40px;
                left: 720px;
                top: 50%;
                border: 1px solid #52B870;
                font-weight: 500;
                font-size: 16px;
                color: #52B870;
                background: none;
                }

                //右箭头
                :deep(.el-carousel__arrow--right){ 
                width: 40px;
                height: 40px;
                left: 1690px;
                top: 50%;
                border: 1px solid #52B870;
                font-weight: 500;
                font-size: 16px;
                color: #52B870;
                background: none;
                }
            .information-item{
                 width: 30%;
                 .img-bp{
                    width: 100%;
                    position: relative;
                    .bg-img{
                        display: block;
                        width: 100%;
                    }
                    .center-msg::after{
                        width: 8px;
                        height: 244px;
                        background: #52B870;
                        border-radius: 6px 0px 0px 6px;
                    }
                    .center-msg{
                        width: 400px;
                        position: absolute;
                        background-image: url('../../assets/banner-bg.png');
                        background-size: 100% 100%;
                        top: 10%;
                        left: 10%;
                        box-sizing: border-box;
                        padding-left: 30px;
                        padding-top: 42px;
                        padding-bottom: 25px;
                        .center-title{
                            width: 228px;
                            font-size: 20px;
                            font-weight: 500;
                            color: #323232;
                        }
                        .center-text{
                            width: 228px;
                            font-size: 10px;
                            font-family: PingFangSC-Regular, PingFang SC;
                            font-weight: 400;
                            margin: 6px 0 30px 0;
                            color: #666666;
                            word-break: break-all;
                            text-overflow: ellipsis;
                            display: -webkit-box;
                            -webkit-box-orient: vertical;
                            -webkit-line-clamp: 3; /* 这里是超出几行省略 */
                            overflow: hidden;
                        }
                        .center-img{
                             display: block;
                             width: 74px;
                             height: 43px;
                        }
                    }
                 }
            }
            .el-carousel__item{
                width: 30%!important;
            }
        }
    }
    .bottom-img{
        width: 100%;
        margin: 30px 0;
        img{
            display: block;
            width: 100%;
        }
    }
    .bottom-msg{
        width: 100%;
        padding: 0 10%;
        box-sizing: border-box;
        .banquan{
            width: 416px;
            padding: 10px 0;
            background: #52B870;
            border-radius: 30px;
            font-weight: 600;
            font-size: 22px;
            text-align: center;
            color: #FFFFFF;
        }
        .tips{
            font-size: 18px;
            font-family: PingFangSC-Semibold, PingFang SC;
            font-weight: 600;
            color: #323232;
            margin: 30px 0;
            span{
                margin-right: 60px;
            }
        }
        .compeny{
            font-size: 18px;
            font-weight: 400;
            color: #666666;
            padding-bottom: 60px;
        }
    } 
}
</style>
<style src="../phone/index.css" lang="scss" scoped></style>
